import { ITEM_STATE } from '../../../types/constants'
import { StylesService } from '../../../types/constants/styles'
import { BASE_COLORS } from '../../../types/interfaces'

export function styles(className: string, stateClassName: string): string {
  return `
    /* ================================= 主容器样式 ================================= */
    .${className} {
      height: 300px;
      display: flex;
      flex-direction: column;
      overflow-y: auto;
      padding: 0;
      height: 400px;
    }

    /* ================================= 搜索框样式 ================================= */
    .search-box {
      padding: 12px 12px 5px 12px;
    }
    
    .search-box input {
      width: 100%;
      padding: 8px 12px;
      border: 1px solid #e1e4e8;
      border-radius: 6px;
      font-size: 14px;
      outline: none;
      transition: border-color 0.2s;
    }
    
    .search-box input:focus {
      border-color: #0366d6;
      box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
    }
    
    .search-toggle-wrapper {
      padding: 0 0 0 12px;
      display: flex;
      align-items: center;
      min-width: 120px; /* 防止切换文本换行 */
      
      .search-toggle {
        display: flex;
        align-items: center;
        cursor: pointer;
        font-size: 14px;
        color: #586069 !important;
        transition: color 0.2s;
      }
        
      .search-toggle:hover {
        color: #0366d6;
      }
        
      .search-toggle input {
        margin-right: 6px;
        accent-color: #0366d6 !important; /* 现代浏览器支持的复选框颜色 */
      }
    }
    
    /* ================================= 搜索结果为空的样式 ================================= */
    .no-results {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      padding: 24px;
      text-align: center;
      color: #666;
      animation: noResultFadeIn 0.3s ease-out;
      .no-results-icon {
        font-size: 32px;
        margin-bottom: 12px;
        opacity: 0.6;
      }
      .no-results-text {
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 8px;
        color: #333;
      }
      .no-results-hint {
        font-size: 13px;
        color: #999;
      }
    }
    
    /* ================================= 选择情况样式 ================================= */
    .selection-status {
      padding: 10px 0;
      .status-item {
        display: flex;
        align-items: center;
        font-size: 14px;
        margin-right: 15px;
        padding: 6px 8px;
        border-radius: 4px;
        border: 1px solid #e1e4e8;
        transition: all 0.2s;
        .status-icon {
          margin-right: 8px;
        }
      }
      
      .status-item.not-selected {
        background-color: #fafbfc;
        border-left: 3px solid #d1d5da;
        .status-icon {
          color: ${ITEM_STATE.SKIPPED.color};
        }
      }
        
      .status-item.selected {
        background-color: #f0fff4;
        border-left: 3px solid #28a745;
        .status-icon {
          color: ${ITEM_STATE.CHANGED.color};
        }
      }
    }
    /* ================================= 菜单组样式 ================================= */
    .menu-groups {
      flex: 1;
      overflow-y: auto;
      padding: 8px 0;
      position: relative;
      min-height: 100px; /* 预留空状态高度 */
      ${StylesService.getInstance().scroll.default}
    }
    
    .menu-group {
      border-bottom: 1px solid #e1e4e8;
    }
    
    /* ================================= 分组标题样式 ================================= */
    .group-header {
      position: relative;
      display: flex;
      align-items: center;
      padding: 8px 12px;
      margin-right: 5px;
      cursor: pointer;
      user-select: none;
      .group-icon {
        margin-right: 8px;
        font-size: 16px;
      }
      
      .group-name {
        font-size: 14px;
        font-weight: bold;
        color: ${BASE_COLORS.TEXT_TITLE} !important;
      }
    }
    
    .group-header:after {
      content: "▼";
      position: absolute;
      right: 12px;
      font-size: 12px;
      color: #c1c5c9;
    }
    
    .group-header.expanded:after {
      transform: rotate(180deg);
      color: #0d6efd;
    }
    
    .group-header.${stateClassName} {
      background-color: #fff3cd;
    }
    
    .group-header:hover {
      background-color: #17a2b8;
      .group-name, .group-cnt {
        color: #fff !important;
      }
    }
    
    /* ================================= 分组内容样式 ================================= */
    .group-items {
      display: none;
      padding-left: 24px;
    }
    
    .group-items.expanded {
      display: block;
    }
    
    /* ================================= 菜单项样式 ================================= */
    .menu-item {
      padding: 6px 12px 6px 24px;
      font-size: 13px;
      color: #24292e;
      cursor: pointer;
      position: relative;
      transition: all 0.2s;
      height: 100%;
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 12px 6px 24px;
      .item-name {
        flex: 1;
      }
      
      .favorite-icon {
        color: #8700ff;
        cursor: pointer;
        font-size: 14px;
        font-weight: bold;
        opacity: 1;
      }
    }
    
    .menu-item:hover {
      background-color: #d0d8e0;
    }
    
    .menu-item:hover .favorite-icon {
      opacity: 0.5;
    }
    
    .menu-item.${stateClassName} .favorite-icon {
      opacity: 1;
    }
    
    .menu-item:before {
      content: "";
      position: absolute;
      left: 12px;
      top: 50%;
      transform: translateY(-50%);
      width: 4px;
      height: 4px;
      background-color: #586069;
      border-radius: 50%;
    }
    
    /* ================================= 菜单项高亮样式 ================================= */
    .menu-item.${stateClassName} {
      background-color: #d4edda;
      color: #0366d6;
      font-weight: 600;
    }

    /* ================================= 面板公共样式 ================================= */
    .element-panel, .style-panel {
      flex: 1;
      overflow-y: auto;
      padding: 8px;
    }

    /* ================================= 分隔线 ================================= */
    .panel-divider {
      width: 1px;
      background: #e1e4e8;
      margin: 8px 0;
    }
        
    /* ================================= 双面板容器 ================================= */
    .panels-wrapper {
      display: flex;
      flex: 1;
      overflow: hidden;
      height: auto;
    }

    /* ================================= 通用面板样式 ================================= */
    .panel {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    .element-panel {
      border-right: 1px solid #e1e4e8;
    }
    
    /* ================================= 样式控制面板 ================================= */
    .style-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      padding: 12px;
      background: #f8f9fa;
      border-radius: 6px;
      margin-top: 12px;
    }
    
    .control-item {
      display: flex;
      flex-direction: column;
      gap: 4px;
      min-width: 120px;
      
      label {
        font-size: 12px;
        color: #6c757d;
      }
      
      input[type="range"] {
        width: 100%;
      }
      
      .unit {
        font-size: 12px;
        color: #6c757d;
        text-align: right;
      }
    }
    
    /* 水平布局 */
    .style-controls.layout-horizontal {
      display: flex;
      flex-wrap: wrap;
    }
    
    /* 垂直布局 */
    .style-controls.layout-vertical {
      display: flex;
      flex-direction: column;
    }
    
    /* 网格布局 */ 
    .style-controls.layout-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    /* 响应式处理 */
    @media (max-width: 768px) {
      /* 小屏幕强制垂直布局 */
      .style-controls {
        flex-direction: column !important;
      }
      
      .style-controls.layout-grid {
        grid-template-columns: 1fr;
      }
    }
  `
}
